import request from "@/utils/request";

const Member_BASE_URL = "/admin/user/list";
const Member_UpdateScore_URL = "/admin/pay/points/change";
const Member_relation_URL = "/admin/hp/relation";
const Member_score_URL = "/admin/hp/record";
const Member_usdt_URL = "/admin/hp/record-u";
const Member_state_URL = "/admin/user/abbr/state";
const Member_ad_list_URL = "/admin/user/ad/list";
const Member_answer_URL = "admin/user/set/answer";
const Member_UpdateUsdt_URL = "admin/pay/u/change";
const Member_cipher_key_URL = "/admin/user/cipher/key";
const Member_export_wallet_key_URL = "/admin/pay/export/wallet-key";

const Member_performance_URL = "/admin/hp/record-perf";

const Level_URL = "/admin/config/member-list";
const LEVEL_EDIT_URL = "admin/config/modify-member";
const LEVEL_Delete_URL = "/admin/config/del-member";

const LEVEL_lists_URL = "admin/adManage/list";
const LEVEL_Save_URL = "/admin/adManage/upload";
const LEVEL_Del_URL = "/admin/adManage/del";

const MemberAPI = {
  /**
   * 获取等级列表
   *
   * @returns 树形表格数据
   */
  getLevelList(params?: MemberQuery) {
    return request<any, LevelVO[]>({
      url: `${Level_URL}`,
      method: "get",
      params,
    });
  },

  updateAnswer(data: any) {
    return request({
      url: `${Member_answer_URL}`,
      method: "post",
      data,
    });
  },

  /**
   * 新增
   *
   * @param data 表单数据
   * @returns 请求结果
   */
  create(data: LevelForm) {
    return request({
      url: `${LEVEL_EDIT_URL}`,
      method: "post",
      data,
    });
  },

  /**
   * 修改
   *
   * @param id ID
   * @param data 表单数据
   * @returns 请求结果
   */
  update(data: LevelForm) {
    return request({
      url: `${LEVEL_EDIT_URL}`,
      method: "post",
      data,
    });
  },

  /**
   * 获取会员列表
   *
   * @param params 查询参数
   * @returns 会员列表
   */
  getList(params?: any) {
    return request<any, any>({
      url: `${Member_BASE_URL}?page=${params?.pageNum || 1}&limit=${params?.pageSize || 10}&account=${params?.keywords || ""}&bnbAddress=${params?.bnbAddress || ""}&tronAddress=${params?.tronAddress || ""}
      &userLevelId=${params?.level_status || ""}&accState=${params?.status || ""}&inviteCode=${params?.inviteCode || ""}&accType=${params?.accType || ""}`,
      method: "get",
    });
  },

  /**
   * 删除
   *
   * @param ids ID，多个以英文逗号(,)分隔
   * @returns 请求结果
   */
  deleteByIds(ids: string) {
    return request({
      url: `${Member_BASE_URL}/${ids}`,
      method: "delete",
    });
  },

  /**
   * 获取广告商列表
   *
   * @returns 树形表格数据
   */
  adList(params?: any) {
    console.log(params);
    return request<any, any>({
      url: `${LEVEL_lists_URL}?page=${params.page}&limit=${params.limit}`,
      method: "get",
      headers: {
        "Content-Type": "multipart/form-data",
      },
    });
  },

  adSave(data: any) {
    return request({
      url: `${LEVEL_Save_URL}`,
      method: "post",
      data,
    });
  },

  adDelete(data: any) {
    return request({
      url: `${LEVEL_Del_URL}`,
      method: "post",
      data,
    });
  },

  updateScore(data: any) {
    return request({
      url: `${Member_UpdateScore_URL}`,
      method: "post",
      data,
    });
  },

  updateUsdt(data: any) {
    return request({
      url: `${Member_UpdateUsdt_URL}`,
      method: "post",
      data,
    });
  },

  Member_relation_URL(data: any) {
    return request({
      url: `${Member_relation_URL}`,
      method: "post",
      data,
    });
  },

  Member_score_URL(data?: any) {
    return request<any, any>({
      url: `${Member_score_URL}`,
      method: "post",
      data,
    });
  },

  Member_cipher_key_URL(data?: any) {
    return request<any, any>({
      url: `${Member_cipher_key_URL}`,
      method: "post",
      data,
    });
  },

  Member_usdt_URL(data?: any) {
    return request<any, any>({
      url: `${Member_usdt_URL}`,
      method: "post",
      data,
    });
  },

  Member_state_URL(data?: any) {
    return request<any, any>({
      url: `${Member_state_URL}`,
      method: "post",
      data,
    });
  },

  LEVEL_Delete_URL(data: any) {
    return request({
      url: `${LEVEL_Delete_URL}`,
      method: "post",
      data,
    });
  },

  Member_ad_list_URL(data?: any) {
    return request<any, any>({
      url: `${Member_ad_list_URL}?page=${data?.page || 1}&limit=${data?.limit || 10}&userId=${data?.userId || ""}`,
      method: "get",
      data,
    });
  },

  Member_export_wallet_key_URL() {
    return request<any, any>({
      url: `${Member_export_wallet_key_URL}`,
      method: "get",
    });
  },

  Member_performance_URL(data?: any) {
    return request<any, any>({
      url: `${Member_performance_URL}`,
      method: "post",
      data,
    });
  },
};

export default MemberAPI;

/** 会员查询参数 */
export interface MemberQuery {
  /** 搜索关键字 */
  keywords?: string;
  /** ID */
  id?: number;
  /** 等级 */
  level?: number;

  pageNum?: number;
  pageSize?: number;
  userLevelId?: string;
  accState?: string;
  inviteCode?: string;
  accType?: string;
}

/** 会员列表 */
export interface MemberVO {
  /** 创建时间 */
  createTime?: string;
  /** ID */
  id?: string;
  /** 昵称 */
  name?: string;
  /** 账号 */
  account?: string;
  /** 排序 */
  sort?: number;
  /** 余额 */
  money?: string;
  /** 积分 */
  score?: string;
  /** 状态 */
  status?: number;
  /** 等级 */
  level?: string;
  /** 头像 */
  avatar?: string;
  /** 邀请码 */
  markId?: string;
}

/** 等级类型 */
export interface LevelVO {
  /** ID(新增不填) */
  id?: string;
  /** 会员级别名称 */
  name?: string;
  /** 开通金额 */
  fee?: string;
  /** 任务奖励 */
  taskRward: string;
  /** 级别 */
  grade?: number;
  /** 总收益天数 */
  effectiveTime?: number;
  /** 状态(1:启用；0：禁用) */
  status?: number;
}

/** 广告商管理 */
export interface ListVO {
  /** 创建时间 */
  createTime?: string;
  /** ID */
  id?: string;
  /** 昵称 */
  name?: string;
  /** 账号 */
  account?: string;
  /** 排序 */
  sort?: number;
  /** 余额 */
  money?: string;
  /** 状态 */
  status?: string;
  /** 等级 */
  level?: string;
  /** 头像 */
  avatar?: string;
}

/** 等级表单类型 */
export interface LevelForm {
  /** ID(新增不填) */
  id?: string;
  /** 会员级别名称 */
  name?: string;
  /** 开通金额 */
  fee?: string;
  /** 任务奖励 */
  taskRward: string;
  /** 级别 */
  grade?: number;
  /** 总收益天数 */
  effectiveTime?: number;
  /** 状态(1:启用；0：禁用) */
  status?: number;
}
